#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e6+10;
ll n,a[N],ans,ord[N];
inline void solv(ll t,ll att){
    if(t>n) return;
    if(a[t]>a[t-1]&&ord[a[t]]>=att) att=ord[a[t]];
    if(ord[a[t]]&&att<=n){
        att++;
        ans--;
    }
    solv(t+1,att);
}
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    ans=n;
    for(ll i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    ll k=a[1];
    for(ll i=2;i<=n;i++){
        if(a[i]>k) ord[k]=i;
        k=a[i];
    }
    solv(1,ord[a[1]]);
    cout<<ans;
    return 0;
}
